package com.htu.courseService.common.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.htu.courseService.common.enums.ErrorCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Created By JNNarrator on 2024/9/6 09:06
 * email: jiangn09@chinatelecom.cn
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R<T>{
	private Integer code;
	private String msg;
	private T data;
	public static <T> R<T> success(T data){
		return new R<>(200,"success",data);
	}
	public static <T> R<T> success(){
		return new R<>(200,"success",null);
	}
	public static R<?> fail(Integer code,String msg){
		return new R<>(code,msg,null);
	}
	public static R<?> fail(ErrorCodeEnum errorCodeEnum){
		return new R<>(errorCodeEnum.getCode(),errorCodeEnum.getMsg(),null);
	}
}
